package com.qcby.chatservice.config.properties;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.redisson.config.ReadMode;
import org.redisson.config.SubscriptionMode;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * redisson属性
 *
 * @author cong.zhen
 * @date 2023/01/18
 */
@ConfigurationProperties(
        prefix = "redisson"
)
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class RedissonProperties {
    private int threads;
    private int nettyThreads;
    private RedissonProperties.SingleServerConfig singleServerConfig;
    private RedissonProperties.ClusterServersConfig clusterServersConfig;
    private List<CacheGroup> cacheGroup;


    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    public static class CacheGroup {
        private String groupId;
        private long ttl;
        private long maxIdleTime;
        private int maxSize;
    }

    /**
     * 集群服务器配置
     *
     * @author cong.zhen
     * @date 2023/01/18
     */
    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    public static class ClusterServersConfig {
        private String clientName;
        private int masterConnectionMinimumIdleSize;
        private int masterConnectionPoolSize;
        private int slaveConnectionMinimumIdleSize;
        private int slaveConnectionPoolSize;
        private int idleConnectionTimeout;
        private int timeout;
        private int subscriptionConnectionPoolSize;
        private ReadMode readMode;
        private SubscriptionMode subscriptionMode;
    }

    /**
     * 单机模式配置
     *
     * @author cong.zhen
     * @date 2023/01/18
     */
    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    public static class SingleServerConfig {
        private String clientName;
        private int connectionMinimumIdleSize;
        private int connectionPoolSize;
        private int idleConnectionTimeout;
        private int timeout;
        private int subscriptionConnectionPoolSize;
    }
}
